package main

import (
	"fmt"
	"time"
)

func main() {
	count := make(chan int, 4)
	t1 := time.NewTicker(2 * time.Second)
	t2 := time.NewTicker(time.Second)
	base := 1000
	go func() {
		for i := 0; i < 5; i++ {
			count <- i + 100
		}
	}()

	for {
		select {
		case <-t2.C:
			fmt.Println("count的元素数", len(count))
		case <-t1.C:
			fmt.Println("每隔一段时间 1s", <-count)
		case count <- base: // 如果可以加入进去
			fmt.Println("加入了一个元素")
			base++
		}
	}

	fmt.Println("$$$$$$$$$$$$$~~~~~~~~~~~~~~")
}
